//
//  ByCellScoreStoreDetailHeader.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/11/8.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellScoreStoreDetailHeader.h"

@implementation ByCellScoreStoreDetailHeader
{
    UIImageView     *_bgView;
    UIImageView     *_mainView;         // 主图
    UILabel         *_nameLabel;        // 名称
    UILabel         *_descLabel;        // 介绍
    
    UILabel         *_openTimeLabel;    // 营业时间
    UILabel         *_callLabel;        // 电话

    UILabel         *_noticeLabel;      // 公告

    UILabel         *_distanceLabel;    // 距离
    UILabel         *_addressLabel;     // 位置
    
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    _bgView = [UIImageView new];
    _bgView.image = [UIImage imageNamed:@"头视图背景"];
    [self.contentView addSubview:_bgView];
    
    _mainView = [UIImageView new];
    _mainView.backgroundColor = BY_RED_COLOR;
    [_bgView addSubview:_mainView];
    
    _nameLabel = [[UILabel alloc] init];
    _nameLabel.text = @"天阳电器";
    _nameLabel.font = FONT(16);
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.textColor = [UIColor blackColor];
    [_bgView addSubview:_nameLabel];
    
    _descLabel = [[UILabel alloc] init];
    _descLabel.text = @"品质保证";
    _descLabel.font = FONT(14);
    _descLabel.textAlignment = NSTextAlignmentCenter;
    _descLabel.textColor = [UIColor lightGrayColor];
    [_bgView addSubview:_descLabel];
    
    
    UIView *centerLine = [UIView new];
    centerLine.backgroundColor = BY_LINE_COLOR;
    [self.contentView addSubview:centerLine];
    
    UIView *line1 = [UIView new];
    line1.backgroundColor = BY_LINE_COLOR;
    [self.contentView addSubview:line1];
    UIView *line2 = [UIView new];
    line2.backgroundColor = BY_LINE_COLOR;
    [self.contentView addSubview:line2];
    
    UIImageView *openTimeIconView = [UIImageView new];
    openTimeIconView.backgroundColor = BY_RED_COLOR;
    [self.contentView addSubview:openTimeIconView];
    
    _openTimeLabel = [[UILabel alloc] init];
    _openTimeLabel.text = @"9:00 - 22:00";
    _openTimeLabel.font = FONT(12);
    _openTimeLabel.textAlignment = NSTextAlignmentCenter;
    _openTimeLabel.textColor = BY_RED_COLOR;
    [self.contentView addSubview:_openTimeLabel];
    
    UIImageView *callIconView = [UIImageView new];
    callIconView.backgroundColor = BY_RED_COLOR;
    [self.contentView addSubview:callIconView];
    
    _callLabel = [[UILabel alloc] init];
    _callLabel.text = @"0544-12345678";
    _callLabel.font = FONT(12);
    _callLabel.textAlignment = NSTextAlignmentCenter;
    _callLabel.textColor = BY_RED_COLOR;
    [self.contentView addSubview:_callLabel];
    
    _noticeLabel = [[UILabel alloc] init];
    _noticeLabel.text = @"公告：欢迎来到天阳电器...";
    _noticeLabel.font = FONT(14);
    _noticeLabel.textAlignment = NSTextAlignmentCenter;
    _noticeLabel.textColor = BY_RED_COLOR;
    [self.contentView addSubview:_noticeLabel];
    
    UIImageView *addressIconView = [UIImageView new];
    addressIconView.backgroundColor = BY_RED_COLOR;
    [self.contentView addSubview:addressIconView];
    
    _addressLabel = [[UILabel alloc] init];
    _addressLabel.text = @"浙江省杭州市浙江省杭州市浙江省杭州市浙江省杭州市浙江省杭州市浙江省杭州市浙江省杭州市";
    _addressLabel.font = FONT(14);
    _addressLabel.textAlignment = NSTextAlignmentLeft;
    _addressLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_addressLabel];
    
    UIView *line3 = [UIView new];
    line3.backgroundColor = BY_LINE_COLOR;
    [self.contentView addSubview:line3];
    
    _distanceLabel = [[UILabel alloc] init];
    _distanceLabel.text = @"200m";
    _distanceLabel.font = FONT(12);
    _distanceLabel.textAlignment = NSTextAlignmentRight;
    _distanceLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_distanceLabel];
    

    
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.height.equalTo(@100);
    }];
    [_mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.height.equalTo(_bgView);
        make.width.equalTo(_mainView.mas_height);
    }];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_mainView.mas_centerY).offset(-5);
        make.left.equalTo(_mainView.mas_right).offset(10);
        make.right.equalTo(@-10);
    }];
    [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_nameLabel);
        make.top.equalTo(_mainView.mas_centerY).offset(5);
    }];
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.right.equalTo(@-10);
        make.top.equalTo(_bgView.mas_bottom).offset(40);
        make.height.equalTo(@1);
    }];
    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.equalTo(line1);
        make.top.equalTo(line1.mas_bottom).offset(40);
    }];
    [centerLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@1);
        make.height.equalTo(@15);
        make.centerY.equalTo(_bgView.mas_bottom).offset(20);
        make.centerX.equalTo(@0);
    }];
    [openTimeIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SCREEN_WIDTH / 10));
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.centerY.equalTo(centerLine);
    }];
    [_openTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(openTimeIconView);
        make.left.equalTo(openTimeIconView.mas_right).offset(10);
    }];
    [callIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(centerLine).offset(SCREEN_WIDTH / 10);
        make.size.centerY.equalTo(openTimeIconView);
    }];
    [_callLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(callIconView);
        make.left.equalTo(callIconView.mas_right).offset(10);
    }];
    [_noticeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(line1);
        make.top.equalTo(line1);
        make.bottom.equalTo(line2);
    }];
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@40);
        make.top.equalTo(line2);
        make.left.equalTo(addressIconView.mas_right).offset(10);
        make.bottom.equalTo(self.contentView);
    }];
    [addressIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.left.equalTo(@10);
        make.centerY.equalTo(_addressLabel);
    }];
    [_distanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-10);
        make.top.height.equalTo(_addressLabel);
        make.left.greaterThanOrEqualTo(_addressLabel.mas_right).offset(20);
    }];
    [line3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_distanceLabel);
        make.height.equalTo(@15);
        make.width.equalTo(@1);
        make.right.equalTo(_distanceLabel.mas_left).offset(-10);
    }];
    
    
}

@end
